package xyz.lwm.lazycat.web.handle;

import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;

/**
 * http response
 *
 * @author lwm
 */
public interface HttpResponse {

    /**
     * send response
     *
     * @param httpStatusCode http status code
     */
    void setStatus(int httpStatusCode);

    /**
     * send response
     *
     * @param httpStatusCode http status code
     * @param bodyLength     body length
     */
    void setStatus(int httpStatusCode, long bodyLength);

    /**
     * is response sent code
     *
     * @return true if sent
     */
    boolean hasSetStatus();

    /**
     * get response headers
     *
     * @return response headers
     */
    Map<String, List<String>> getHeaders();

    /**
     * add response header
     *
     * @param header header
     * @param value  value
     */
    void addHeader(String header, String value);

    /**
     * set response header
     *
     * @param header header
     * @param value  value
     */
    void setHeader(String header, String value);

    /**
     * set response header
     *
     * @param header header
     * @param value   value
     */
    void setHeader(Header header, String value);

    /**
     * set response headers
     *
     * @param headers headers
     */
    void setHeaders(Map<String, List<String>> headers);

    /**
     * set response content type
     *
     * @param contentType content type
     */
    void setContentType(String contentType);

    /**
     * set response content length
     *
     * @param contentLength content length
     */
    void setContentLength(long contentLength);

    /**
     * set response charset
     *
     * @param charset charset
     */
    void setCharset(Charset charset);

    /**
     * set response attr
     *
     * @param key   key
     * @param value value
     */
    void setAttr(String key, String value);

    /**
     * get response output stream
     *
     * @return output stream
     */
    OutputStream getOut();

    /**
     * write response
     *
     * @param data data
     */
    void write(String data);

    /**
     * write response
     *
     * @param data data
     */
    void write(byte[] data);

    /**
     * write response
     *
     * @param in input stream
     */
    void write(InputStream in);

    /**
     * write response
     *
     * @param in       input stream
     * @param length   length
     */
    void write(InputStream in, int length);

    /**
     * write response
     *
     * @param in           input stream
     * @param length       length
     * @param contentType  content type
     * @param fileName     file name
     */
    void write(InputStream in, int length, String contentType, String fileName);

}
